/**
 * @Author：ming
 * @Date：2023/9/25 9:56 PM
 * @Filename：Lc27
 */

/**
 * @author ming
 */
public class Lc27 {
    public int removeElement(int[] nums, int val) {
        int count = 0;
        int len = nums.length;
        int l = 0;
        while (l<len){
            if(nums[l]==val){

                if(l==len-1){
                    break;
                }
                for (int i = l; i < len-1; i++) {
                    nums[i] = nums[i+1];
                }
                len--;
            }else {
                count++;
                l++;
            }
        }
        return count;
    }
}
